package com.tocea.formation.tpLibraryEjb.util;

import java.util.ArrayList;
import java.util.List;
import javax.ejb.Stateless;

import com.tocea.formation.tpLibraryEjb.DTO.AuthorDTO;
import com.tocea.formation.tpLibraryEjb.entities.Author;

@Stateless
public class AuthorConvert {
		
	public AuthorConvert(){}

	public static AuthorDTO convert(Author a){
		a = new Author();
		return new AuthorDTO(a.getId(), a.getFirstname(), a.getLastname(), a.getAge());
	}
	
	public static List<AuthorDTO> convertFromListAuthorToListDTO(List<Author> lista){
		List<AuthorDTO> list = new ArrayList<AuthorDTO>();
		for (Author author : lista) {
			list.add(AuthorConvert.convert(author));
		}
		return list;
		
	}
	
}
